﻿
@{
    ViewBag.Title = "EmergencyPlanAdd";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@section css{
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <style>
        #location {
            position: absolute;
            z-index: 100;
            width: 10px;
            height: 10px;
            color: red;
            font-weight: bold;
        }

        .div-relative {
            position: relative;
        }

        .div-a {
            position: absolute;
        }
    </style>
}

<header id="topbar">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a>添加应急事件</a>
            </li>
            <li class="crumb-link">
                <a>应急预案</a>
            </li>
            <li class="crumb-trail">添加应急事件</li>
        </ol>
    </div>
</header>

<div id="content" ng-cloak ng-controller="EmergencyController" ng-init="GetFactoryList();AddModel.FactoryAreaId='1';AddModel.Status='1';GetLocationList(AddModel.FactoryAreaId);">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-info panel-border top mb35">
                <div class="panel-heading">
                    <span class="panel-title">添加应急事件</span>
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-lg-2 control-label">厂区：</label>
                            <div class="col-lg-8">
                                <select class="form-control" ng-model="AddModel.FactoryAreaId" ng-change="GetLocationList(AddModel.FactoryAreaId);">
                                    <option value="0" selected>请选择地点...</option>
                                    <option ng-repeat="x in FactoryList" value="{{x.Id}}">{{x.Factory}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">发生地点：</label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="地点名称..." ng-model="AddModel.LocationName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">位置坐标：</label>
                            <div class="col-sm-1">
                                <input type="text" class="form-control" placeholder="X" ng-model="AddModel.X" readonly />
                            </div>
                            <div class="col-sm-1">
                                <input type="text" class="form-control" placeholder="Y" ng-model="AddModel.Y" readonly />
                            </div>
                            <div class="col-sm-1">
                                <a data-toggle="modal" href="#mapModal" class="btn btn-info">选择位置坐标</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上报时间</label>
                            <div class="col-sm-8">
                                <datepicker id="startTime" option="datetimeOption" format="L HH:mm" ng-model="AddModel.ReportTime"></datepicker>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">上报人</label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="此处输入上报人..." ng-model="AddModel.ReportUser">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label" for="textArea2">上报问题</label>
                            <div class="col-lg-8">
                                <textarea class="form-control" id="textArea2" rows="3" ng-model="AddModel.Description"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label" for="textArea2">当前状态</label>
                            <div class="col-lg-8">
                                <select class="form-control" ng-model="AddModel.Status">
                                    <option>选择状态...</option>
                                    <option value="1">进行中</option>
                                    <option value="2">已处理</option>
                                </select>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="panel-footer">
                    <div class="col-lg-2"></div>
                    <button type="button" class="btn btn-primary" ng-click="AddEventForm(AddModel);">提交</button>
                    <div class="col-lg-2"></div>
                    <button type="button" class="btn btn-warning">重置页面</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="mapModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">厂区地图</h2>
                </div>
                <div class="modal-body">
                    <div class="div-relative" id="mapContent">
                        <div id="location" style="left:50%;top:50%;">
                            <i class="fa fa-map-marker"></i>
                        </div>
                        <img src="~/Bussiness/img/pvg.png" width="950" ng-show="AddModel.FactoryAreaId=='1'" />
                        <img src="~/Bussiness/img/dcArea.jpg" width="950" ng-show="AddModel.FactoryAreaId=='2'" />
                        <div ng-repeat="location in LocationList">
                            <div class="div-a" ng-style="{'left':location.X+'%','top':location.Y+'%'}">
                                <div style="font-size:12px; border-radius:4px;cursor:pointer;">
                                    <a class="titlediv" style="color:gainsboro;" title="{{location.BuildingName}}">{{location.SimpleName}}</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <input type="hidden" id="h_XAxis" value="0" />
                    <input type="hidden" id="h_YAxis" value="0" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="SelectPosition(AddModel)">确定</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>

@section Js{
    <script src="~/Bussiness/js/libs/upload.js"></script>
    <script src="~/Bussiness/js/pg/EmergencyPlan.js?v=@DateTime.Now.ToString("yyMMddHHmm")"></script>
    <script src="~/Bussiness/js/libs/moment.min.js"></script>
    <script src="~/Bussiness/js/libs/locales/date/zh-cn.js"></script>
    <script src="~/Bussiness/js/libs/bootstrap-datetimepicker.min.js"></script>
    <script src="~/Bussiness/js/libs/angularjs-datepicker.js"></script>
    <script src="~/Bussiness/js/libs/fileinput.js"></script>
    <script src="~/Bussiness/js/libs/zh.js"></script>
    <script>
        $('#docfiles').fileinput({
            language: 'zh'
        });

        $("#mapContent").mousedown(function (e) {
            var width = $("#mapContent").width();
            var height = $("#mapContent").height();
            mouseX1 = (e.pageX - $("#mapContent").offset().left) / width;
            mouseY1 = (e.pageY - $("#mapContent").offset().top) / height;
            $("#location").css({ 'left': mouseX1 * 100 + '%', 'top': mouseY1 * 100 + '%' });
            $("#h_XAxis").val(mouseX1);
            $("#h_YAxis").val(mouseY1);
        });
    </script>
}